package com.hx.hospital.service.impl;


import com.hx.hospital.mapper.QuestionMapper;
import com.hx.hospital.pojo.Question;
import com.hx.hospital.service.QuestionService;
import org.apache.dubbo.config.annotation.Service;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

import static com.hx.hospital.service.impl.UserServiceImpl.LOGIN;

@Service
public class QuestionServiceImpl implements QuestionService {

    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private QuestionMapper questionMapper;


    @Override
    public void insertQuestion(Question question, String token) {
        //为了获取当前用户的电话号码
        String phone = RpcContext.getContext().getAttachment(LOGIN + token);
        question.setPhone(phone);
        questionMapper.insert(question);

    }
}
